<?php

// $Id: functions.php 3 2010-05-27 16:25:49Z alistair.mills@btinternet.com $

function db_open ($host) {
    $db = false;
    if ($host == "http://localhost") {
       if (@mysql_connect("localhost", "root")) {
          $db = true;
       } else {
          echo "Database server is off line<br>";
          $db = false;
       }
       if ($db && @mysql_select_db("guinguette")) {
          $db = true;
       } else {
          echo "Database server is up, but database is off line<br>";
          $db = false;
       }
    } else {
       if (@mysql_connect("localhost", "alistai6_crcam", "guyfox05")) {
          $db = true;
       } else {
          echo "Database server is off line<br>";
          $db = false;
       }
       if ($db && @mysql_select_db("alistai6_guinguette")) {
          $db = true;
       } else {
          echo "Database server is up, but database is off line<br>";
          $db = false;
       }
    }
    return $db;
}

function build_index ($SELECT, $trans, $translator){

       $array1 = array();
       $array2 = array();
       $sql    =
          $SELECT;
       $sql_        = addslashes($sql);
       $sql__       = get_magic_quotes_runtime() ? $sql_ : $sql;
       $reponse     = mysql_query($sql__) or die(mysql_error());
       while ($un_trans = mysql_fetch_assoc($reponse)) {
          $trans_r       = $un_trans [$trans];
          $translator_r  = $un_trans [$translator];
          $array1[]      = $trans_r;
          $array2[]      = $translator_r;
       }
       mysql_free_result($reponse);
       $translators = array_combine($array1, $array2);
       return $translators;

}

?>
